#coding=utf-8
import stockdb.misc as misc
import strategy.basic as basic

def weipan_filter(td, t='14:31', change=2):

    close = td.close
    p = td.price_on(t)
    
    c = (close-p) *100.0 / p 
    
    if c >= change:return True
    return False

if __name__ == '__main__':

    date = '2008-06-10'
    date = misc.today
    print date
    
    tds = misc.find_tds_on(date)
    print len(tds)
    tf = basic.TDFilter(tds)

    tds = tf.filter_by(basic.tdattr_filter, 'close', 5, 25).\
             filter_by(weipan_filter).\
             all()

    for td in tds:
        s = td.fins
        print s.code, s.name
        


    
